//
//  BaseTableViewController.swift
//  仿一个新浪微博
//
//  Created by 孙家林 on 15/9/9.
//  Copyright © 2015年 sunjialin. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {


    ///用户登录标记
    var userLogin = UserAccount.userLogin
    
        ///设置访客视图
    var visitorView:VisitorLoginView?
    
    override func loadView() {
            
        ///根据用户是否登录判断是否替换根视图
        userLogin ? super.loadView() : setUpVisitorView()

    }
    
    private func setUpVisitorView() {
            
        visitorView = VisitorLoginView()
            
        visitorView?.delegate = self
        
        view = visitorView
            
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
            
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
            
    }
        
    func visitorLoginViewWillLogin() {
            
        let nav = UINavigationController(rootViewController: OAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
            print("注册")
    }
    
}
